package com.bw.visit

import androidx.databinding.DataBindingUtil
import com.bw.lib_base.entity.VisitBeanItem
import com.bw.visit.databinding.ItemVisitBinding
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class VisitAdapter: BaseQuickAdapter<VisitBeanItem,BaseViewHolder>(R.layout.item_visit) {
    override fun onItemViewHolderCreated(viewHolder: BaseViewHolder, viewType: Int) {
        super.onItemViewHolderCreated(viewHolder, viewType)
        DataBindingUtil.bind<ItemVisitBinding>(viewHolder.itemView)
    }
    override fun convert(helper: BaseViewHolder, item: VisitBeanItem) {
        val binding = DataBindingUtil.getBinding<ItemVisitBinding>(helper.itemView)
        binding?.bean = item
        binding?.visitStatus?.apply {
            when(item.visitStatus){
                "待审核" ->{
                    setTextColor(helper.itemView.context.getColor(R.color.orange))
                    setBackgroundResource(R.drawable.shape_status2)
                }
                "已完成" ->{
                    setTextColor(helper.itemView.context.getColor(R.color.black))
                    setBackgroundResource(R.drawable.shape_solid_lightgray)
                }
                "驳回" ->{
                    setTextColor(helper.itemView.context.getColor(R.color.red))
                    setBackgroundResource(R.drawable.shape_status3)
                }
                else ->{
                    setTextColor(helper.itemView.context.getColor(R.color.green))
                    setBackgroundResource(R.drawable.shape_status)
                }
            }
        }
    }
}